home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / misc / emu / amiSPIMsrc.lha / reg.h < prev    next >
C/C++ Source or Header  |  1994-01-17  |  3KB  |  135 lines

  1. /* SPIM S20 MIPS simulator.
  2.    Declarations of registers and code for accessing them.
  3.    Copyright (C) 1990-1994 by James Larus (larus@cs.wisc.edu).
  4.    ALL RIGHTS RESERVED.
  5.  
  6.    SPIM is distributed under the following conditions:
  7.  
  8.      You may make copies of SPIM for your own use and modify those copies.
  9.  
  10.      All copies of SPIM must retain my name and copyright notice.
  11.  
  12.      You may not sell SPIM or distributed SPIM in conjunction with a
  13.      commerical product or service without the expressed written consent of
  14.      James Larus.
  15.  
  16.    THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  17.    IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  18.    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19.    PURPOSE. */
  20.  
  21.  
  22. /* $Header: /home/primost/larus/Software/SPIM/RCS/reg.h,v 3.8 1994/01/18 03:21:45 larus Exp larus $
  23. */
  24.  
  25.  
  26. typedef long reg_word;
  27.  
  28.  
  29. /* General purpose registers: */
  30.  
  31. extern reg_word R[32];
  32.  
  33. extern reg_word HI, LO;
  34. #ifdef CL_SPIM
  35. extern int HI_present, LO_present;
  36. #endif
  37.  
  38. extern mem_addr PC, nPC;
  39.  
  40.  
  41. /* Argument passing registers */
  42.  
  43. #define REG_V0 2
  44. #define REG_A0 4
  45. #define REG_A1 5
  46. #define REG_A2 6
  47. #define REG_A3 7
  48. #define REG_FA0 12
  49. #define REG_SP 29
  50.  
  51.  
  52. /* Result registers */
  53.  
  54. #define REG_RES 2
  55. #define REG_FRES 0
  56.  
  57.  
  58. /* $gp registers */
  59.  
  60. #define REG_GP 28
  61.  
  62.  
  63.  
  64. /* Floating Point Coprocessor (1) registers :*/
  65.  
  66. extern double *FPR;        /* Dynamically allocate so overlay */
  67. extern float *FGR;        /* is possible */
  68. extern int *FWR;        /* is possible */
  69.  
  70.  
  71. extern int FP_reg_present;    /* Presence bits for FP registers */
  72. extern int FP_reg_poison;    /* Poison bits for FP registers */
  73. extern int FP_spec_load;    /* Is register waiting for a speculative load */
  74.  
  75.  
  76. #define FPR_S(REGNO) (((REGNO) & 0x1) \
  77.               ? (run_error ("Bit 0 in FP reg spec\n") ? 0.0 : 0.0)\
  78.               : FGR[REGNO])
  79.  
  80. #define FPR_D(REGNO) (double) (((REGNO) & 0x1) \
  81.                    ? (run_error ("Bit 0 in FP reg spec\n") ? 0.0 : 0.0)\
  82.                    : FPR[(REGNO) >> 1])
  83.  
  84. #define FPR_W(REGNO) (((REGNO) & 0x1) \
  85.               ? (run_error ("Bit 0 in FP reg spec\n") ? 0 : 0)\
  86.               : FWR[REGNO])
  87.  
  88.  
  89. #define SET_FPR_S(REGNO, VALUE) {if ((REGNO) & 0x1) \
  90.                  run_error ("Bit 0 in FP reg spec\n");\
  91.                  else FGR[REGNO] = (double) (VALUE);}
  92.  
  93. #define SET_FPR_D(REGNO, VALUE) {if ((REGNO) & 0x1) \
  94.                  run_error ("Bit 0 in FP reg spec\n");\
  95.                  else FPR[(REGNO) >> 1] = (double) (VALUE);}
  96.  
  97. #define SET_FPR_W(REGNO, VALUE) {if ((REGNO) & 0x1) \
  98.                  run_error ("Bit 0 in FP reg spec\n");\
  99.                  else FWR[REGNO] = (int) (VALUE);}
  100.  
  101.  
  102. /* Floating point control and condition registers: */
  103.  
  104. #define FCR        CPR[1]
  105. #define FPId        (CPR[1][0])
  106. #define FpCond        (CPR[1][31])
  107.  
  108.  
  109.  
  110. /* Other Coprocessor Registers.  The floating point registers
  111.    (coprocessor 1) are above.  */
  112.  
  113. extern reg_word CpCond[4], CCR[4][32], CPR[4][32];
  114.  
  115.  
  116. /* Exeception Handling Registers (actually registers in Coprocoessor
  117.    0's register file) */
  118.  
  119. int exception_occurred;
  120.  
  121. #define EntryHI         (CPR[0][0])
  122. #define EntryLO         (CPR[0][1])
  123. #define Index           (CPR[0][2])
  124. #define Random          (CPR[0][3])
  125. #define Context        (CPR[0][4])
  126. #define BadVAddr    (CPR[0][8])
  127. #define Status_Reg    (CPR[0][12])
  128. #define Cause        (CPR[0][13])
  129. #define EPC        (CPR[0][14])
  130. #define PRId        (CPR[0][15])
  131.  
  132.  
  133. #define USER_MODE (Status_Reg & 0x2)
  134. #define INTERRUPTS_ON (Status_Reg & 0x1)
  135.